 #ifndef NODE_H
 #define NODE_H

 #include <QGraphicsItem>
 #include <QList>
#include "traffic_sim.h"
#include <QObject>
#include "agent.h"
 
class Edge;
class GraphWidget;
class Semaphore;
//class Agent;
class QGraphicsSceneMouseEvent;
using namespace Traffic_Sim;

 class Node : public QObject, public QGraphicsItem
 {
  Q_OBJECT
 
 public:
     Node(GraphWidget *graphWidget, Traffic_Sim::Traffic_Node_Info & info );
     void addEdge(Edge *edge);
     QList<Edge *> edges() const;
     Node * searchNode(int x, int y);	
     enum { Type = UserType + 1 };
     int type() const { return Type; }
     bool advance();
     QRectF boundingRect() const;
     QPainterPath shape() const;
     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
     Semaphore * addSemaphore(Traffic_Semaphore * sem);
     void paintSemaphore(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
     Agent * addAgent(Traffic_Vehicle * vehicle);

protected:
    QVariant itemChange(GraphicsItemChange change, const QVariant &value);
     void mousePressEvent(QGraphicsSceneMouseEvent *event);
     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
 public:
     QList<Edge *> edgeList;
     QPointF newPos;
     GraphWidget *graph;
     Traffic_Sim::Traffic_Node_Info info;
 };

 #endif
